Answer:

From a static viewpoint, what is wrong?

The base case Triangle(1) = 1 was left out of the Java code.

From a dynamic viewpoint, what is wrong?

The method always calls for another activation regardless of the value of the parameter, so the chain of activation keeps growing until system resources run out.

Computational Advantages of Iteration and Recursion

Recursion is useful because sometimes a problem is naturally recursive. Then all you need to do is match it with Java code. But recursion does not add any fundamental power to Java.

Any method that is written using recursion can be written using iteration. Any method that is written using iteration can be written using recursion.

A computer programming language needs to include only one of iteration or recursion to be as powerful as any other programming language. Some languages (such as early FORTRAN) have only iteration. Other languages (such as early LISP) have only recursion. Most modern languages have both, because both are convenient.

QUESTION 18:

Is there an iterative version of Triangle?